package csc.com.dao;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;

import csc.com.model.Employee;
import csc.com.service.EmployeeMapper;

public class EmployeeDAO {
	
	private EmployeeMapper employeeMapper;
	private JdbcTemplate jdbcTemplate;

	public EmployeeMapper getEmployeeMapper() {
		return employeeMapper;
	}
	@Autowired
	public void setEmployeeMapper(EmployeeMapper employeeMapper) {
		this.employeeMapper = employeeMapper;
	}
	public JdbcTemplate getJdbcTemplate() {
		return jdbcTemplate;
	}
	@Autowired
	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}
	
	
	
	public List<Employee> getEmployees() {
		// TODO Auto-generated method stub
		  String SQL = "select * from employees";
	      List <Employee> employees = jdbcTemplate.query(SQL, 
	                                employeeMapper);
	      return employees;
	}
	public void addEmployee(String id, String name, String address, String phone,
			String email) {
		// TODO Auto-generated method stub
		  String SQL = "insert into employees (employeeid, name, address, phone, email) values (?, ?, ?, ?, ?)";
	      jdbcTemplate.update( SQL, id, name, address, phone, email);
	      return;
	}
	public void deleteEmployee(String employeeid) {
		// TODO Auto-generated method stub
		  String SQL = "delete from employees where employeeid = ?";
	      jdbcTemplate.update(SQL, employeeid);
	      return;
	}
	  
}
